<template>
  <svg-icon
    icon-class="copy"
    className="copy-icon"
    :size="20"
    pointer
    v-show="props.text"
    @click="handleCopy"
  />
</template>
<script setup lang="ts" name="CopyTextButton">
import { defineProps } from "vue";
import { copyText } from "@/utils";
import PsMessage from "@/components/message/index";
const props = defineProps({
  text: {
    type: String
  },
  showTip: {
    type: Boolean,
    default: true
  }
});
function handleCopy(){
  if (props.text) {
    copyText(props.text)
    props.showTip && PsMessage('复制成功')
  }
}
</script>
<style lang="scss" scoped>
.copy-icon{
  &:hover {
    color: var(--el-color-primary);
  }
}
</style>
